<template>
  <el-dialog v-model="visible" title="本局结算" width="400px" :close-on-click-modal="false" :show-close="false">
    <div v-if="winners.length">
      <div v-for="winner in winners" :key="winner.id" style="margin-bottom: 8px;">
        <span style="font-weight:bold; color: #67c23a;">{{ winner.nickname }}</span> 获胜，赢得 {{ winner.chips }} 筹码！
      </div>
    </div>
    <div v-else>暂无结算信息</div>
    <template #footer>
      <el-button type="primary" @click="close">知道了</el-button>
    </template>
  </el-dialog>
</template>
<script lang="ts" setup>
import { ref, watch, defineProps, defineEmits } from 'vue'
const props = defineProps<{ visible: boolean; winners: { id: number; nickname: string; chips: number }[] }>()
const emit = defineEmits(['update:visible'])
const visible = ref(props.visible)
watch(() => props.visible, v => visible.value = v)
function close() {
  visible.value = false
  emit('update:visible', false)
}
</script> 